package com.kim.smartring.utils;

public class HexStringUtils {
	public static byte[] parseHexStringToBytes(final String hex) {
		String tmp = hex.substring(2).replaceAll("[^[0-9][a-f]]", "");
		byte[] bytes = new byte[tmp.length() / 2]; // every two letters in the
													// string are one byte
													// finally

		String part = "";

		for (int i = 0; i < bytes.length; ++i) {
			part = "0x" + tmp.substring(i * 2, i * 2 + 2);
			bytes[i] = Long.decode(part).byteValue();
		}

		return bytes;
	}
}
